{% extends 'home/template.html' %}

{% load i18n %}
{% load bleach_tags %}
{% block title %} {% translate "Templates" %} {% endblock title %}

{% block stylesheets %}
  {{ block.super }}
{% endblock stylesheets %}

{% block content %}

  <section class="content-header">
    <div class="container-fluid">
      <div class="row mb-2">
        <div class="col-sm-4">
          <h1>{% translate "Finding Templates" %}</h1>
        </div>
        <div class="col-sm-8">
          <ol class="breadcrumb float-sm-right">
            <li class="breadcrumb-item"><a href="/">{% translate "Home" %}</a></li>
            <li class="breadcrumb-item"><a href="{% url 'customer_view' DB_report_query.product.customer.pk %}">{{ DB_report_query.product.customer.name | bleach}}</a></li>
            <li class="breadcrumb-item"><a href="{% url 'product_view' DB_report_query.product.pk %}">{{ DB_report_query.product.name | bleach}}</a></li>
            <li class="breadcrumb-item"><a href="{% url 'report_view' DB_report_query.pk %}">{{ DB_report_query.title}}</a></li>
            <li class="breadcrumb-item active">{% translate "Add finding from template" %}</a></li>
          </ol>
        </div>
      </div>


    </div>
  </section>


  <section class="content">

    <div class="container-fluid">
      <div class="card card-outline card-danger">
        <div class="card-header">
          <h3 class="card-title">{% translate "Templates" %}</h3>

          <div class="card-tools">
            <button type="button" class="btn btn-tool" data-card-widget="collapse" title="Collapse">
              <i class="fas fa-minus"></i>
            </button>
          </div>
        </div>
        <div class="card-body">

          <div class="row">
            <div class="col-md-12">


          <table id="templatelist" class="table table-bordered table-hover">
              <thead>
                  <tr>
                    <th style="width: 40%">{% translate "Finding title" %}</th>
                    <th style="width: 5%">{% translate "Severity" %}</th>
                    <th style="width: 35%">{% translate "CVSS Score" %}</th>
                    <th style="width: 20%" class="text-center">{% translate "Actions" %}</th>
                  </tr>
              </thead>
              <tbody>

                {% for template in DB_findings_query %}
                  <tr>
                    <td class=" last">{{ template.title }}</td>

                    <td>
                        
                        {% if template.severity == "Critical" %}
                            <b><font color="#CC0000">{{template.severity}}</font></b>
                        {% elif template.severity == "High" %}
                            <b><font color="#F20000">{{template.severity}}</font></b>
                        {% elif template.severity == "Medium" %}
                            <b><font color="#FC7F03">{{template.severity}}</font></b>
                        {% elif template.severity == "Low" %}
                            <b><font color="#05B04F">{{template.severity}}</font></b>
                        {% elif template.severity == "Info" %}
                            <b><font color="#45A7F7">{{template.severity}}</font></b>
                        {% else %}
                            <b>{{template.severity}}</b>
                        {% endif %}

                    </td>

                    <td>
                        {{template.cvss_vector}}
                    </td>

                    <td align="center">
                        <a href="{% url 'templateaddreport' template.pk DB_report_query.pk %}"><button type="button" class="btn btn-danger btn-sm"><i class="fa fa-folder"></i> {% translate "Add Finding to Report" %}</button></a>
                    </td>
        

                  </tr>

                {% endfor %}
                  
                </tbody>
              </table>

        </div>
      </div>
    </div>
  </section> 


{% endblock content %}

{% block javascripts %}
  {{ block.super }}

<script>
  $(function () {
    $("#templatelist").DataTable({
      "paging": true,
      "searching": true,
      "responsive": true,
      "lengthChange": false,
      "autoWidth": false,
      "ordering": true,
      "buttons": ["copy", "csv", "excel", "pdf", "print", "colvis"]
    }).buttons().container().appendTo('#templatelist_wrapper .col-md-6:eq(0)');
  });
</script>

{% endblock javascripts %}
